﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    $(function() {
        gridList();
    });

    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/Project/Pathway/GetGridJsonAuto",
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "F_Id", hidden: true, key: true },
                {
                    label: '股道名称',
                    name: 'gudao',
                    width: 100,
                    align: 'center'
                },
                {
                    label: '车数',
                    name: 'CarNumber',
                    width: 100,
                    align: 'center',
                    formatter: function(cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue : "0";
                    }
                },
                {
                    label: '股道信息',
                    name: 'xingxi',
                    width: 910,
                    align: 'center',
                    formatter: function(cellvalue) {
                        debugger;
                        return cellvalue != null ? cellvalue : "没有车辆信息";
                    }
                }
            ],
            pager: "#gridPager",
            sortname: 'CompositeIntegral desc',
            viewrecords: true

        });
        $("#btn_search").click(function() {
            $gridList.jqGrid('setGridParam',
                {
                    postData: {
                        keyword: $("#txt_keyword").val(),
                        name: $("#txt_name").val()
                    },
                }).trigger('reloadGrid');
        });

        $("#btn_export").click(function() {
            window.location.href = "/Project/Pathway/GetGridExportExcell";
        });
        $("#btn_export_carBox").click(function() {
            window.location.href = "/Project/Pathway/GetGridExportCarBoxExcell";
        });
    }

    function btn_details() {
        var keyValue = $("#gridList").jqGridRowValue().gudao;
        var keyValue2 = encodeURI(keyValue);
        $.modalOpen({
            id: "Details",
            title: "查看股道详情",
            url: encodeURI("/Project/Pathway/Details?keyValue=" + keyValue2),
            width: "1440px",
            height: "820px",
            btn: null
        });
    }

    function btn_edit() {
        var keyValue = $("#gridList").jqGridRowValue().gudao;
        var keyValue2 = encodeURI(keyValue);
        //alert(keyValue2);
        $.modalOpen({
            id: "Index",
            title: "股道添加车辆",
            url: encodeURI("/Project/PickCar/Index?keyValue=" + keyValue2),
            width: "1400px",
            height: "800px",
            callBack: function(iframeId) {
                top.frames[iframeId].submitForm();
                setTimeout(function() {
                        $.reload();
                        $.currentWindow().$("#gridList").trigger("reloadGrid");
                        gridList();
                    },
                    700);
            }
        });
    }

    function btn_RetPaiche() {
        var keyValue = $("#gridList").jqGridRowValue().gudao;
        $.modalConfirm("确定要回退此股道的排车吗？",
            function(r) {
                if (r) {
                    $.submitForm({
                        url: "/Project/Pathway/RetClearCarByGudao",
                        param: { keyValue: keyValue },
                        success: function() {
                            $.currentWindow().$("#gridList").trigger("reloadGrid");
                        }
                    });
                }
            });
    }

    function btn_Paiche() {
        var keyValue = $("#gridList").jqGridRowValue().gudao;
        $.modalConfirm("确定要排车吗，完成此操作将清空此股道中所有车辆信息",
            function(r) {
                if (r) {
                    $.submitForm({
                        url: "/Project/Pathway/ClearCarByGudao",
                        param: { keyValue: keyValue },
                        success: function() {
                            $.currentWindow().$("#gridList").trigger("reloadGrid");
                        }
                    });
                    //$.ajax({
                    //    url: "/Project/Pathway/ClearCarByGudao",
                    //    data: { keyValue: keyValue },
                    //    type: "get",
                    //    dataType: "json",
                    //    success: function (data) {
                    //        if (data.state == "success") {
                    //            options.success(data);
                    //            $.modalMsg(data.message, data.state);
                    //        } else {
                    //            $.modalAlert(data.message, data.state);
                    //        }
                    //    },
                    //    error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //        $.loading(false);
                    //        $.modalMsg(errorThrown, "error");
                    //    },
                    //    beforeSend: function () {
                    //        $.loading(true, options.loading);
                    //    },
                    //    complete: function () {
                    //        $.loading(false);
                    //    }
                    //});
                }
            });
        //alert(keyValue);
    }

    function btn_deleteByCarCode() {
        $.modalOpen({
            id: "Details",
            title: "查看股道详情",
            url: encodeURI("/Project/Pathway/DelCarByCarcode"),
            width: "920px",
            height: "820px",
            btn: null
        });
    }
</script>

<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
           总车辆：  @ViewBag.gudaocount
            @*<a id="NF-add" class="btn btn-primary dropdown-text" onclick="btn_add()"><i class="fa fa-plus"></i>新增股道</a>*@
        </div>
        <div class="operate">
            <ul class="nav nav-pills">
                <li class="first">已选中<span>1</span>项</li>
                @*<li><a id="NF-edit" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>修改股道</a></li>
        <li><a id="NF-delete" onclick="btn_delete()"><i class="fa fa-trash-o"></i>删除股道</a></li>*@
                <li><a id="NF-Details" onclick="btn_details()"><i class="fa fa-search-plus"></i>查看详情</a></li>
                <li><a id="NF-edit" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>添加车辆</a></li>
                <li><a id="NF-delete" onclick="btn_Paiche()"><i class="fa fa-trash-o"></i>排车</a></li>
                <li><a id="NF-deleteByCarCode" onclick="btn_deleteByCarCode()"><i class="fa fa-trash-o"></i>通过车号删除股道中车辆</a></li>
                <li><a id="NF-Retdelete" onclick="btn_RetPaiche()"><i class="fa fa-trash-o"></i>回退此股道排车</a></li>
                <li class="split"></li>
                <a style="margin-left:55%; margin-top:-6%" class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
                <a href="javascript:;" class="close"></a>
            </ul>
         
        </div>
        <script>$('.toolbar').authorizeButton()</script>
    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group" style="padding-left:11px;padding-right:10px;">
                        @*<input id="txt_keyword" type="text" class="form-control" placeholder="按照课程名称模糊搜索" style="width: 200px; margin-right:20px;">*@
                        @*<select id="txt_state" class="form-control" style="width: 120px;margin-right:20px;" placeholder="按照状态搜索">
            <option value="">请选择</option>
            <option value="0">未审核</option>
            <option value="1">审核驳回</option>
            <option value="2">审核中</option>
            <option value="3">审核通过</option>

        </select>*@
                        @*<input id="txt_name" type="text" class="form-control" placeholder="按照场主名称模糊搜索" style="width: 200px; margin-right:20px;">
        <span class="input-group-btn">
            <button id="btn_search" type="button" class="btn  btn-primary active"><i class="fa fa-search"></i></button>
        </span>*@

                        <span class="input-group-btn">
                            <button id="btn_export" style="margin-left: 30px;padding-left: 7px;padding-right: 7px;" type="button" class="btn  btn-primary active">导出车辆汇总</button>
                        </span>
                        <span class="input-group-btn">
                            <button id="btn_export_carBox" style="margin-left: 30px;padding-left: 7px;padding-right: 7px;" type="button" class="btn  btn-primary active">导出箱号汇总</button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
<style>
    table tr td {
        padding-left: 15px;
    }
</style>
<div class="gridPanel">
    <table id="gridList"></table>
    <div id="gridPager"></div>
</div>
